<h1>View Participation <?php echo $participation->getId()?></h1>

<?php //include_stylesheets_for_form($form) ?>
<?php //include_javascripts_for_form($form) ?>

  <table>
    <tbody>
      <?php //echo $form->renderGlobalErrors() ?>
      <tr>
        <th>ID: </th>
        <td><?php echo $participation->getId() ?></td>
      </tr>
      <tr>
        <th>Recepient: </th>
        <td><?php echo $participation->getRecepient() ?></td>
      </tr>
      <tr>
        <th>Town: </th>
        <td><?php echo $participation->getRecepient()->getTown() ?></td>
      </tr>
      <tr>
        <th>Inputs: </th>
        <td><?php echo $participation->getInputstring() ?></td>
      </tr>
      <tr>
        <th>Inputs Delivered: </th>
        <td><?php 
              if($participation->getInputdeliverydate())
              {
                echo MyDateTime::frommysql($participation->getInputdeliverydate())->toprettydate();
              }
              else
              {
                $participation->setInputdeliverydate(MyDateTime::today()->tomysql());
                $form=new ParticipationForm($participation->getRawValue());
                echo form_tag_for($itemform, 'participation/setdeliverydate');
                echo $form->renderHiddenFields();
                echo '<input type="hidden" name="id" id="id" value='.$participation->getId().'/>';
                echo $form["inputdeliverydate"];
                echo '<input type="submit" value="Save" />';
                echo '</form>';
              }
              
              ?></td>
      </tr>
      <tr>
        <th>Batch: </th>
        <td><?php echo link_to($participation->getBatch(),"@batch_show?id=".$participation->getBatchId()) ?></td>
      </tr>
      <tr>
        <th>Status: </th>
        <td><?php echo $participation->getStatus(); if($participation->getNextStatus())echo " ".link_to("(Set as ".$participation->getNextStatus().")","participation/nextstatus?id=".$participation["id"]); ?></td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="2">
          &nbsp;<?php echo link_to('Delete', 'participation/delete?id='.$participation->getid(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          &nbsp;<?php echo link_to('Edit', 'participation/edit?id='.$participation->getid()) ?>
          <br>
          &nbsp;<a href="<?php echo url_for('batch/show?id='.$participation['batch_id']) ?>">Return to Batch</a>
          <br>
          &nbsp;<a href="<?php echo url_for('participation/index') ?>">Return to Participations List</a>
        </td>
      </tr>
    </tfoot>
  </table>

<br>
<br>

  <?php echo form_tag_for($itemform, '@participation_detail') ?>
    <?php echo $itemform->renderHiddenFields() ?>
    <input type="hidden" name="participation_detail[participation_id]" id="participation_detail_participation_id" value="<?php echo $participation->getId()?>" />
    <?php if ($itemform->hasGlobalErrors()): ?>
      <?php echo $itemform->renderGlobalErrors() ?>
    <?php endif; ?>
  <table>
      <tr>
        <th><?php echo 'Input' ?></th>
        <th>  </th>
        <th><?php echo 'Quantity' ?></th>
        <th>  </th>
        <th><?php echo 'Price' ?></th>
      </tr>
      <tr>
        <td><?php echo $itemform['input_id']->renderError() ?></td>
        <td>  </td>
        <td><?php echo $itemform['qty']->renderError() ?></td>
        <td>  </td>
        <td><?php echo $itemform['price']->renderError() ?></td>
      </tr>
      <tr>
        <td><?php echo $itemform['input_id'] ?></td>
        <td>  </td>
        <td><?php echo $itemform['qty'] ?></td>
        <td>  </td>
        <td><?php echo $itemform['price'] ?></td>
        <td>  </td>
        <td><input type="submit" value="Add Item" /></td>
      </tr>
  </table>
</form>

<br>
<br>
  <table>
    <tbody>
      <tr valign=top>
        <th><?php echo 'Input' ?></th>
        <th> | </th>
        <th><?php echo 'Quantity' ?></th>
        <th> | </th>
        <th><?php echo 'Price' ?></th>
        <th> | </th>
        <th><?php echo 'Edit' ?></th>
        <th> | </th>
        <th><?php echo 'Delete' ?></th>
      </tr>
      <?php foreach($items as $item){ 
      ?>
      <tr>
        <td><?php echo $item->getInput() ?></td>
        <td> | </td>
        <td><?php echo $item->getQty() ?></td>
        <td> | </td>
        <td><?php echo $item->getPrice() ?></td>
        <td> | </td>
        <td><a href="<?php echo url_for('participation_detail/edit?id='.$item['id']) ?>"><?php echo "Edit" ?></a></td>
        <td> | </td>
        <td><?php echo link_to('Delete', 'participation_detail/delete?id='.$item['id'], array('method' => 'delete', 'confirm' => 'Delete input entry: '.$item->getInput()." - ".$item->getQty()." : P".$item->getPrice().' Are you sure?')) ?></td>
      </tr>
      <?php } ?>
  </table>
  

